package holder;

import com.example.googlemarketdemo.R;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;

import conf.constants.URLS;

import utils.BitmapHepler;
import utils.UIUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.RatingBar;
import android.widget.TextView;
import base.BaseHolder;
import bean.AppInfoBean;
/**
 * 详情页面app描述的信息
 * @author Anson-pc
 *
 */
public class AppDetailInfoHolder extends BaseHolder<AppInfoBean> {

	private TextView mTv;
	/*-----------  获取控件 ----------*/
	@ViewInject(R.id.app_detail_info_rb_star)
	RatingBar mRbStar;
	@ViewInject(R.id.app_detail_info_iv_icon)
	ImageView mIvIcon;
	
	@ViewInject(R.id.app_detail_info_tv_downloadnum)
	TextView mTvDownLoadNum;
	@ViewInject(R.id.app_detail_info_tv_name)
	TextView mTvName;
	@ViewInject(R.id.app_detail_info_tv_size)
	TextView mTvSize;
	@ViewInject(R.id.app_detail_info_tv_time)
	TextView mTvTime;
	@ViewInject(R.id.app_detail_info_tv_version)
	TextView mTvVersion;
	/*--------- end ----------*/

	@Override
	protected View initHolderView() {
		View view = View.inflate(UIUtils.getContext(), R.layout.item_detail_info, null);
		//获取控件
		ViewUtils.inject(this, view);
		
		return view;
	}

	@Override
	protected void refreshHolderView(AppInfoBean data) {
		//绑定数据
		String date = UIUtils.getString(R.string.detail_date, data.date);
		String downloadnum = UIUtils.getString(R.string.detail_downloadnum, data.downloadNum);
		String size = UIUtils.getString(R.string.detail_size, data.size);
		String version = UIUtils.getString(R.string.detail_version, data.version);	
		//绑定数据
		mTvDownLoadNum.setText(downloadnum);
		mTvName.setText(data.name);
		mTvSize.setText(size);
		mTvTime.setText(date);
		mTvVersion.setText(version);
		mRbStar.setRating(data.stars);
		mIvIcon.setImageResource(R.drawable.ic_default);
		BitmapHepler.display(mIvIcon, URLS.IMAGEBASEURL + data.iconUrl);
		
	}

}
